<template>
  <div class="hm_detail">
    <van-nav-bar title="面经详细" left-text="返回" @click-left="onClickLeft" />
    <div class="botton">
      <h1>{{ obj.stem }}</h1>
      <div class="info">
        <span>{{ obj.createdAt }}</span>
        <span>|</span>
        <span>{{ obj.views }} 浏览量</span>
        <span>|</span>
        <span>{{ obj.likeCount }} 点赞数</span>
      </div>

      <div class="qian">
        <img :src="obj.avatar" alt="" />
        <span>{{ obj.creator }}</span>
      </div>

      <div class="content" v-html="obj.content">
      </div>
    </div>
    <div class="opt">
        <van-icon name="like-o" :class="{active:obj.likeFlag}" @click="c_like" ></van-icon>
        <van-icon name="star-o" :class="{active:obj.collectFlag}" @click="c_collect" ></van-icon>
    </div>
  </div>
</template>

<script>
import { getArticleDetail } from "@/utils/request";
import { Toast } from "vant";
export default {
  name: "HmDetail",
  data() {
    return {
      obj: {},
    };
  },
  mounted() {
    getArticleDetail(this.$route.query.id).then((res) => {
      this.obj = res.data;
      console.log("3456", this.obj);
    });
  },

  methods: {
    onClickLeft() {
      Toast("返回");
      this.$router.back();
    },
    onClickRight() {
      Toast("按钮");
    },
    c_like(){
     this.obj.likeFlag = !this.obj.likeFlag;
     if(this.obj.likeFlag){
      this.obj.likeCount++;
     }else{
      this.obj.likeCount--;
     }
    },
    c_collect(){
      this.obj.collectFlag = !this.obj.collectFlag;
      if(this.obj.collectFlag){
        this.obj.collectCount++;
       }else{
        this.obj.collectCount--;
       }
    },
   
  },
};
</script>

<style scoped lang="less">
.hm_detail {
  position: relative;
box-sizing: border-box;
  .botton {
    padding: 0 16px;
    .info {
      color: #999;
      font-size: 12px;
      margin: 12px 0;
      span {
        margin-right: 5px;
      }
    }
    .qian {
      display: flex;
      align-items: center;

      img {
        width: 40px;
        height: 40px;
        border-radius: 50%;
      }
      span {
        font-size: 12px;
        color: #999;
      }
    }

    .content {
      text-indent: 2em;
      font-size: 16px;
      color: #000;
    }
  }
  .opt {
    position:fixed;
    right: 16px;
    bottom: 100px;
    >.van-icon{
      font-size: 18px;
      width: 40px;
      height: 40px;
      background: #fff;
      border-radius: 50%;
      text-align: center;
      line-height: 40px;
      border-radius: 50%;
      margin-right: 10px;
      &.active{
        background-color: #FEC635;
        color: #fff;
      }
      
    }

   
  }
}
</style>
